namespace Vin.Tool.Core.BasicTypeCategory;

public static partial class Extension
{
    public static DateTime ToDateTime(this long? value, bool isMilliseconds = true)
    {
        if (!value.HasValue)
            return DateTime.MinValue;
        var startTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();
        return isMilliseconds
            ? startTime.AddMilliseconds(value.Value)
            : startTime.AddSeconds(value.Value);
    }

    public static DateTime ToDateTime(this long value, bool isMilliseconds = true)
    {
        var startTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();
        return isMilliseconds
            ? startTime.AddMilliseconds(value)
            : startTime.AddSeconds(value);
    }
}